package com.example.artemis.events;

import java.time.LocalDateTime;

/**
 * 消息事件基类
 * 所有消息相关事件的基础类，包含通用的事件信息
 */
public abstract class MessageEvent {

    private final String messageId;
    private final String queueName;
    private final long timestamp;
    private final LocalDateTime eventTime;

    protected MessageEvent(String messageId, String queueName) {
        this.messageId = messageId;
        this.queueName = queueName;
        this.timestamp = System.currentTimeMillis();
        this.eventTime = LocalDateTime.now();
    }

    /**
     * 获取消息ID
     */
    public String getMessageId() {
        return messageId;
    }

    /**
     * 获取队列名称
     */
    public String getQueueName() {
        return queueName;
    }

    /**
     * 获取事件时间戳（毫秒）
     */
    public long getTimestamp() {
        return timestamp;
    }

    /**
     * 获取事件时间
     */
    public LocalDateTime getEventTime() {
        return eventTime;
    }

    /**
     * 获取事件类型
     */
    public abstract String getEventType();

    @Override
    public String toString() {
        return String.format("%s{messageId='%s', queueName='%s', timestamp=%d, eventType='%s'}",
                getClass().getSimpleName(), messageId, queueName, timestamp, getEventType());
    }
}